<?php
/**
 * This file is part of Hyperf Mall.
 *
 * @link     https://gitee.com/scwlkj/hypref_mall
 * contact  hyperf_mall@163.com
 */
namespace App\JsonRpc;

use App\Repository\MemberBalanceRepository;
use Hyperf\RpcServer\Annotation\RpcService;
use App\JsonRpc\Interfaces\MemberBalanceServiceInterface;

/**
 * @RpcService(name="Member::MemberBalanceService", protocol="jsonrpc", server="jsonrpc")
 */
class MemberBalanceService extends BaseService implements MemberBalanceServiceInterface
{
    public function init()
    {
        $this->repository = MemberBalanceRepository::getInstance();
    }

    /**
     * Notes: 加余额
     * Author: Bruce.z
     * DateTime: 2022/8/22 10:52
     * @param int $member_id
     * @param float $money
     * @return int
     */
    public function incMoney(int $member_id, float $money):int
    {
        return $this->repository->incMoney($member_id, $money);
    }

    /**
     * Notes:减余额
     * Author: Bruce.z
     * DateTime: 2022/8/22 10:52
     * @param int $member_id
     * @param float $money
     * @return int
     */
    public function decMoney(int $member_id, float $money):int
    {
        return $this->repository->decMoney($member_id, $money);
    }

    /**
     * Notes: 售后退款到余额
     * Author: Bruce.z
     * DateTime: 2022/8/22 11:17
     * @param int $member_id
     * @param float $money
     * @param string $oid
     * @return mixed
     */
    public function afterMoney(int $member_id, float $money, string $oid)
    {
        return $this->repository->afterMoney($member_id, $money, $oid);
    }
}
